-
Notifications
You must be signed in to change notification settings - Fork 144
Implement all CSV reader options #1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
FYI @djouallah |
nuno-faria
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| If you require additional control over how to read the CSV file, you can use | ||
| :py:class:`~datafusion.options.CsvReadOptions` to set a variety of options. | ||
|
|
||
| .. code-block:: python | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to have a link to docs.rs or similar that points to all available options for CsvReadOptions.
| terminator: Optional line terminator character. If ``None``, uses CRLF. | ||
| Must be a single ASCII character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised the default is CRLF.
| csv_content = "name;age;city\nAlice;30;New York\nBob;25\n#Charlie;35;Paris" | ||
| csv_path.write_text(csv_content) | ||
|
|
||
| ctx = SessionContext() | ||
|
|
||
| # Test with CsvReadOptions | ||
| options = CsvReadOptions( | ||
| has_header=True, delimiter=";", comment="#", truncated_rows=True | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should more parameters be tested? Like "quote", "truncated_rows", "compression", "null_regex", ...
Which issue does this PR close?
Closes #1358
Rationale for this change
This change allows access to ALL csv reader options available in the upstream DataFusion repository. It adds a builder pattern on setting options for a more pleasant user experience, or they can specify each value individually in the constructor.
What changes are included in this PR?
CsvReaderOptionsclass and underlying structread_csvandregister_csvAre there any user-facing changes?
This change is fully backwards compatible.